package com.yunhai.device.controller;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.yunhai.common.dto.PaginationVo;
import com.yunhai.common.dto.Ret;
import com.yunhai.device.service.FdsEarlywarningRulesetService;
import com.yunhai.model.entity.fds.FdsEarlywarningRulesetEntity;
import com.yunhai.model.vo.fds.FdsEarlywarningRulesetQuery;
import com.yunhai.model.vo.fds.FdsEarlywarningRulesetVo;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

@RestController
@RequestMapping("/fdsEarlywarningRuleset")
public class FdsEarlywarningRulesetController {

	@Resource
	private FdsEarlywarningRulesetService fdsEarlywarningRulesetService;


	/**
	 * 获取 FdsEarlywarningRuleset 分页列表
	 */
	@GetMapping("/pagination")
	public Ret getFdsEarlywarningRulesetPagination(PaginationVo paginationVo, FdsEarlywarningRulesetQuery fdsEarlywarningRulesetQuery ) throws Exception {
		IPage page = fdsEarlywarningRulesetService.getFdsEarlywarningRulesetPagination(paginationVo, fdsEarlywarningRulesetQuery );
		return Ret.toPage(page);
	}


	/**
	 * 获取 FdsEarlywarningRuleset 所有数据
	 */
	@GetMapping("/allList")
	public Ret getFdsEarlywarningRulesetAllList( FdsEarlywarningRulesetQuery fdsEarlywarningRulesetQuery ) throws Exception {
		List<FdsEarlywarningRulesetEntity> list = fdsEarlywarningRulesetService.getFdsEarlywarningRulesetAllList( fdsEarlywarningRulesetQuery );
		return Ret.ok(list);
	}


	/**
	 * 获取 FdsEarlywarningRuleset 详情
	 */
	@GetMapping("/{id}")
	public Ret getFdsEarlywarningRulesetDetailById(@PathVariable Long id) throws Exception {

	    FdsEarlywarningRulesetEntity fdsEarlywarningRulesetEntity = fdsEarlywarningRulesetService.getFdsEarlywarningRulesetDetail(id);
		return Ret.ok(fdsEarlywarningRulesetEntity);
	}


	/**
	 * 新增 FdsEarlywarningRuleset
	 * */
	@PostMapping("")
	public Ret addFdsEarlywarningRuleset(@RequestBody FdsEarlywarningRulesetVo fdsEarlywarningRulesetVo) throws Exception {

		fdsEarlywarningRulesetService.addFdsEarlywarningRuleset(fdsEarlywarningRulesetVo);
		return Ret.ok();
	}


	/**
	 * 更新 FdsEarlywarningRuleset
	 * */
	@PutMapping("")
	public Ret updateFdsEarlywarningRuleset(@RequestBody FdsEarlywarningRulesetVo fdsEarlywarningRulesetVo) throws Exception {

		fdsEarlywarningRulesetService.updateFdsEarlywarningRuleset(fdsEarlywarningRulesetVo);
		return Ret.ok();
	}


	/**
	 * 删除 FdsEarlywarningRuleset
	 * */
	@PostMapping("/batchRemove")
	public Ret batchRemoveFdsEarlywarningRuleset( @RequestBody List<Long> ids ) throws Exception {

	    fdsEarlywarningRulesetService.batchRemoveFdsEarlywarningRuleset(ids);
		return Ret.ok();
	}
}
